<%@ page language="java"
	import="java.util.*,entity.*,service.impl.*,service.*,java.text.SimpleDateFormat,java.lang.*"
	contentType="text/html; charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%  

String path = request.getContextPath();  

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  

%>  
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>contest 页面</title>
<!--
        	作者：胡慧姣
        	描述：引用bootstrap样式和js
        	版本说明：bootstrap 3.3.7   jquery3.3.1
        -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<script src="js/jquery-3.3.1.min.js" type="text/javascript"
	charset="utf-8"></script>
<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>

<!--
        	作者：胡慧姣
        	描述：引用额外的图标库
        -->
<link rel="stylesheet" href="css/iconfont.css" />

<!--
        	作者：胡慧姣
        	描述：主页的css样式
        -->
<link rel="stylesheet" type="text/css" href="css/contest.css" />
<%
	Date now = new Date(); 
	SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");//可以方便地修改日期格式
	session.setAttribute("dateFormat", dateFormat);
	session.setAttribute("now", now);
	System.out.println(request.getParameter("currentPage"));
	System.out.println(request.getParameter("pageSize"));
	if(request.getParameter("typeName") != null && request.getParameter("currentPage")!= null && request.getParameter("pageSize") != null)
    {
		System.out.println(1);
		int a = Integer.parseInt(request.getParameter("currentPage"));
		int b = Integer.parseInt(request.getParameter("pageSize"));
		List<Contest> contests = new ContestDAOImpl().filterAllByType(a, b, request.getParameter("typeName"));
		session.setAttribute("contests", contests);
		session.setAttribute("typeName", request.getParameter("typeName"));
		session.setAttribute("currentPage", request.getParameter("currentPage"));
		session.setAttribute("pageSize", request.getParameter("pageSize"));
	} else {
		System.out.println(2);
		int a = 1;
		int b = 10;
		List<Contest> contests = new ContestDAOImpl().queryAllDefault(a,b); 
		session.setAttribute("contests", contests);
		session.setAttribute("currentPage", request.getParameter("currentPage"));
		session.setAttribute("pageSize", request.getParameter("pageSize"));
	}
%>
</head>
<body>

	<%@ include file="header.jsp" %>
	
	<div class="row clearfix" id="mid">
		<div class="col-md-12 column">
			<div class="middle">
				<div class="title">
					<div class="type_div">
						<span class="type_title">竞赛类别</span>
					</div>
					<ul class="nav-tabs nav" id="tabs1">
						<li class="active"><a href="#tabs-1">工科</a></li>
						<li><a href="#tabs-2">文体</a></li>
						<li><a href="#tabs-3">理科 </a></li>
						<li><a href="#tabs-4">商科 </a></li>
						<li><a href="#tabs-5">综合</a></li>
					</ul>
					<div class="tab-content" id="tab_contents">
						<div class="tab-pane active" id="tabs-1">
							<ul style="list-style: none;">
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=数学建模">数学建模</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=程序设计">程序设计</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=机器人">机器人</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=工程机械">工程机械</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=土木建筑">土木建筑</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=大数据">大数据</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=交通车辆">交通车辆</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=航空航天">航空航天</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=船舶海洋">船舶海洋</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=环境能源">环境能源</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=计算机&信息技术">计算机&信息技术</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=材料高分子">材料高分子</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=电子&自动化">电子&自动化</a></li>
							</ul>
						</div>
						<div class="tab-pane" id="tabs-2">
							<ul style="list-style: none;">
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=外语">外语</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=模特">模特</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=体育">体育</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=UI设计">UI设计</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=服装设计">服装设计</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=电子竞技">电子竞技</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=科技文化艺术节">科技文化艺术节</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=工业&创意设计">工业&创意设计</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=演讲主持&辩论">演讲主持&辩论</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=歌舞书画&摄影">歌舞书画&摄影</a></li>
							</ul>
						</div>
						<div class="tab-pane" id="tabs-3">
							<ul style="list-style: none;">
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=数学">数学</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=物理">物理</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=化学化工">化学化工</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=力学">力学</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=健康生命&医学">健康生命&医学</a></li>
							</ul>
						</div>
						<div class="tab-pane" id="tabs-4">
							<ul style="list-style: none;">
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=创业">创业</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=商业">商业</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=创青春">创青春</a></li>
							</ul>
						</div>
						<div class="tab-pane" id="tabs-5">
							<ul style="list-style: none;">
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=挑战杯">挑战杯</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=环保公益">环保公益</a></li>
								<li><a
									href="contest.jsp?currentPage=1&pageSize=10&typeName=社会综合">社会综合</a></li>
							</ul>
						</div>
					</div>
				</div>
				<div class="level" id="lev">
					<div class="type_div">
						<span class="type_title">竞赛级别</span>
					</div>
					<ul>
						<li><a href="#">校级</a></li>
						<li><a href="#">市级</a></li>
						<li><a href="#">省级</a></li>
						<li><a href="#">国家级</a></li>
						<li><a href="#">国际级</a></li>
						<li><a href="#">自由</a></li>
					</ul>
				</div>
				<div class="sort" id="sor">
					<div class="type_div">
						<span class="type_title">排序方式</span>
					</div>
					<ul>
						<li><a href="#">近期报名</a></li>
						<li><a href="#">最近更新</a></li>
					</ul>
					<div id="checkSchool">
						<input type="checkbox">选定学校 <a href="#">清华大学</a> <a
							href="#">更改</a>
					</div>
				</div>
				<div class="contest_content" id="contest_content_div">
					<div class="content" id="content_div">
						<div id="test">
							<c:forEach var="contest" items="${contests}">
								<c:set var="time" scope="session"
									value="${(((dateFormat.parse(contest.signupEndTime)).getTime()-now.getTime())/(1000*60*60*24)).longValue()}" />
								<c:if test="${time > 0}">
									<div id="contest_right">
										<span class="contest_baoming">立即报名</span> <span
											class="contest_jiezhi">距离报名截止还有 <c:out
												value="${(((dateFormat.parse(contest.signupEndTime)).getTime()-now.getTime())/(1000*60*60*24)).longValue()}" />

											天
										</span> <a class="contest_xiangqing" href="contest_detail.jsp?contestName=${contest.contestName}">竞赛详情>></a>
									</div>

									<div id="contest_title">
										<span class="signup_status"><c:out
												value="${contest.status}" /></span> <span class="signup_title">
												<a href="contest_detail.jsp?contestName=${contest.contestName}"><c:out value="${contest.contestName}" /></a></span>
									</div>
									<div id="contest_contents">
										<ul>
											<%
												SponsorDAOImpl sponsor = new SponsorDAOImpl();
												session.setAttribute("sponsor", sponsor);
											%>
											<c:set var="sponsor1"
												value="${sponsor.queryBySponsor_id(contest.sponsorId)}"
												scope="session" />
											<li><span class="sp1">主办方&nbsp;&nbsp;&nbsp;&nbsp;</span>
												<span class="sp2"><c:out
														value="${sponsor1.sponsorName}" /></span></li>
											<li><span class="sp1">竞赛级别</span> <span class="sp2">国家级</span>
											</li>
											<li><span class="sp1">报名时间</span><span class="sp2">
													<c:out value="${contest.signupStartTime}" />~<c:out
														value="${contest.signupEndTime}" />
											</span></li>
											<li><span class="sp1">比赛时间</span> <span class="sp2">
													<c:out value="${contest.contestStartTime}" />~<c:out
														value="${contest.contestEndTime}" />
											</span></li>
										</ul>
									</div>
								</c:if>
							</c:forEach>
						</div>
					</div>
					<ul class="pagination" id="pagination_ul">
						<li><a href="contest.jsp?currentPage=<c:out value='${currentPage-1}' />&pageSize=<c:out value='${pageSize}'/>&typeName=<c:out value='${typeName}'/>">«</a></li>
						<li class="active"><a
							href="contest.jsp?currentPage=1&pageSize=10&typeName=<c:out value='${typeName}'/>">1</a></li>
						<li><a
							href="contest.jsp?currentPage=2&pageSize=10&typeName=<c:out value='${typeName}'/>">2</a></li>
						<li><a
							href="contest.jsp?currentPage=3&pageSize=10&typeName=<c:out value='${typeName}'/>">3</a></li>
						<li><a
							href="contest.jsp?currentPage=4&pageSize=10&typeName=<c:out value='${typeName}'/>">4</a></li>
						<li><a
							href="contest.jsp?currentPage=5&pageSize=10&typeName=<c:out value='${typeName}'/>">5</a></li>
						<li><a
							href="contest.jsp?currentPage=6&pageSize=10&typeName=<c:out value='${typeName}'/>">6</a></li>
						<li><a href="contest.jsp?currentPage=<c:out value='${currentPage+1}' />&pageSize=<c:out value='${pageSize}'/>&typeName=<c:out value='${typeName}'/>">»</a></li>
					</ul>
				</div>
				<script>
					//竞赛类别tab效果
					$(function() {
						$("#tabs1 a").mousemove(function(e) {
							$(this).tab('show');
						});
						$("#tabs2 a").mousemove(function(e) {
							$(this).tab('show');
						});
						$("#tabs3 a").mousemove(function(e) {
							$(this).tab('show');
						});
						$("#tabs4 a").mousemove(function(e) {
							$(this).tab('show');
						});
						$("#tabs5 a").mousemove(function(e) {
							$(this).tab('show');
						});
					});
				</script>
			</div>
		</div>
	</div>

	<%@ include file="bottom.jsp" %>

</body>
</html>
